package com.nec.recommend.config.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * BigDecimal序列化
 * @author songkaikai
 * @since 2022/7/18
 */
public class BigDecimalSerializer extends JsonSerializer<Object> {

    @Override
    public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        BigDecimal decimal = (BigDecimal) value;
        gen.writeString(decimal.toPlainString());
    }
}
